import { createApp } from 'vue'
import Antd from 'ant-design-vue'
import App from './App.vue'
import 'ant-design-vue/dist/antd.css'
import router from './router'
import microApp from '@micro-zoe/micro-app'
import config from '../src/utils/config'
microApp.start({
  plugins: {
    modules: {
      'appname-vite': [
        {
          loader(code) {
            if (process.env.NODE_ENV === 'development') {
              // 这里 /basename/ 需要和子应用vite.config.js中base的配置保持一致
              code = code.replace(/(from|import)(\s*['"])(\/child\/vite\/)/g, all => {
                return all.replace('/child/vite/', `${config.vite}/child/vite/`)
              })
            }

            return code
          }
        }
      ]
    }
  }
})

createApp(App).use(router).use(Antd).mount('#app')
